<?php
/**
 * Created by PhpStorm.
 * User: dell
 * Date: 2019/3/26
 * Time: 13:44
 */
namespace Modules\ApiV2\Controllers;
use Illuminate\Http\Request;
use Modules\Service\Logic\GoodsLogic;

class GoodsController extends BaseController{
    //商品类型
    public function goodsClassList(Request $request){
        return GoodsLogic::goodsClass();
    }

    //精选商品和热门商品
    public function goodsSelectedList(Request $request){
        $page = $request->input("page",1);
        $limit = $request->input("limit",20);
        return GoodsLogic::goodsSelectedOrHot($page,$limit);
    }

    //商品列表
    public function goodsList(Request $request){
        $classId = $request->input("class_id",false);
        $typeId = $request->input("type_id");
        $sort = $request->input("sort",'id');
        $desc = $request->input("way",'desc');
        $page = $request->input("page",1);
        $limit = $request->input("limit",20);
        if (!$classId)return self::fail(1003,"缺少必要参数:class_id");
        if(empty($sort)) $sort = 'id';
        if(empty($desc)) $desc = 'desc';
        return GoodsLogic::goodsClassById($classId,$typeId,$sort,$desc,$page,$limit);
    }

    //商品详情
    public function goodsDetailById($id){
        return GoodsLogic::goodsDetail($id);
    }

}